/*
 * @lc app=leetcode id=154 lang=cpp
 *
 * [154] Find Minimum in Rotated Sorted Array II
 */
class Solution {
public:
    int findMin(vector<int>& nums) {
 
        int len = nums.size();
        int i = 0, j = len-1;
        int mid = 0;
        while (i < j) {
            mid = (i+j)/2;
            if (nums[mid] < nums[j]) {
                j = mid;
            } else {
                i = mid + 1;
            }
        }

        return nums[i];
    }       
    }
};

